Repository navigation
Conversation
Codex direct-execs hooks.json commands via argv split, not a shell. wrapPosixHookCommand's if/then/fi guard became argv0=`if` → exit 127 and Broken pipe on every managed hook (stablyai#8110). Emit `/bin/sh '<path>'` for Codex local/WSL/SSH installs, keep the guarded wrapper for shell-based agents, and still recognize legacy guarded trust hashes on remove. Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughCodex POSIX trust cleanup now recognizes guarded, direct, readable, executable, and legacy command variants, including timeout-bearing and timeout-free hashes. WSL runtime tests cover legacy trust replacement, shell execution with 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/agent-hooks/installer-utils.ts (1)
134-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSingle-quote escaping logic is duplicated across three call sites.
The
`'${scriptPath.replaceAll("'", "'\\''")}'`POSIX-quoting expression is repeated verbatim inwrapPosixHookCommand(this file),wrapPosixDirectHookCommand(this file), and again inline incodexPosixTrustCommandVariants(src/main/codex/hook-service.ts:148). Extracting a shared exported helper would reduce the risk of the escaping logic silently diverging across sites.♻️ Proposed shared helper
+export function posixSingleQuote(value: string): string { + return `'${value.replaceAll("'", "'\\''")}'` +} + export function wrapPosixHookCommand(scriptPath: string, env: Record<string, string> = {}): string { - const quoted = `'${scriptPath.replaceAll("'", "'\\''")}'` + const quoted = posixSingleQuote(scriptPath) ... } export function wrapPosixDirectHookCommand(scriptPath: string): string { - const quoted = `'${scriptPath.replaceAll("'", "'\\''")}'` + const quoted = posixSingleQuote(scriptPath) return `/bin/sh ${quoted}` }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f36fe6ac-4a3e-40d6-bb65-c1c7592b09ba
📒 Files selected for processing (5)
src/main/agent-hooks/installer-utils.test.tssrc/main/agent-hooks/installer-utils.tssrc/main/codex/hook-service-wsl-runtime.test.tssrc/main/codex/hook-service.test.tssrc/main/codex/hook-service.ts
Current Codex launches hooks via $SHELL -lc with the full command as one arg, so if/then/fi would work — but stablyai#8110's 127 also matches pure whitespace argv-exec (argv0=`if`) and quoted `/bin/sh 'path'` fails that model because quotes stay in the path token. Emit unquoted `/bin/sh <path>` when the path is argv-safe; fall back to single-quoted paths for spaces/metacharacters. Keep legacy trust variants for remove. Co-Authored-By: Claude <noreply@anthropic.com>
…0-current # Conflicts: # src/main/codex/hook-service-wsl-runtime.test.ts # src/main/codex/hook-service.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review Please review current head bef0a65 after the CI-discovered test contract fix. |
|
✅ Action performedReview finished.
|
|
Closing as unsupported after exact-head audit. The direct launcher reintroduced the same exit-127/Broken-pipe class when the managed script is missing and could not support quoted home paths under the claimed naive splitter. Head 305bf6b restores the safe guarded behavior before closure. Issue #8110 remains open pending an exact reporter runtime and child-argv trace. |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/main/codex/hook-service.ts (1)
142-154: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract shared POSIX quoting in
hook-service.tsThe
'${scriptPath.replaceAll("'", "'\\''")}'quoting is duplicated acrosswrapReadablePosixHookCommand,getLegacyDirectPosixHookCommand, andcodexPosixTrustCommandVariants. Pull it into a local helper so the guarded/readable/legacy command variants stay in sync.src/main/codex/hook-service-wsl-runtime.test.ts (1)
83-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSolid execution-regression coverage; helper is correct.
runInstalledHookcorrectly spawns/bin/shwith array args, captures stdin errors instead of throwing, and times out defensively. The "spaces and quotes" loop test (259-289) relies oninstallManagedHooksIntoWslRuntimewriting the actual script atplan.scriptPathduring install (confirmed by the sibling test'srmSync(plan.scriptPath, ...)at line 306), so both/bin/sh -cand-lcexecutions genuinely exercise the real script, not just the drain fallback.One nit: this "spaces and quotes" execution loop is nearly identical to the one added in
src/main/agent-hooks/installer-utils.test.ts(Lines 320-337) — same home-name fixtures ('Jorge Silva',"O'Brien"), same shell-flag loop, same assertion shape. Consider extracting a shared test helper (e.g., a small fixture module exporting the home-name list and arunUnderShellwrapper) to keep both suites in sync as quoting rules evolve.Also applies to: 259-313
src/main/agent-hooks/installer-utils.test.ts (1)
14-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winGood regression coverage for quoted/spaced POSIX paths; minor cross-file duplication.
The new loop correctly writes, chmods, and executes the script via
spawnSync('/bin/sh', [shellFlag, wrapPosixHookCommand(scriptPath)]), validating both-cand-lcinvocation styles against tricky path characters — good defense against the quoting regression this PR fixes.As noted in the companion file, this test is structurally identical to the new "spaces and quotes" loop added in
src/main/codex/hook-service-wsl-runtime.test.ts(Lines 259-289): samehomeNamefixtures and shell-flag loop, just exercisingwrapPosixHookCommanddirectly instead of through the WSL installer. Worth consolidating into a shared helper/fixture to avoid future drift between the two.Also applies to: 320-337
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e9a7eaf7-f1fd-4922-9671-03c9d5246654
📒 Files selected for processing (5)
src/main/agent-hooks/installer-utils.test.tssrc/main/agent-hooks/remote-hook-service-installers.test.tssrc/main/codex/hook-service-wsl-runtime.test.tssrc/main/codex/hook-service.test.tssrc/main/codex/hook-service.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/codex/hook-service.test.ts
Closeout
Do not merge. The original root-cause claim was overturned by primary-source and runtime evidence, so this PR is closed as unsupported rather than landing a harmful compatibility change.
Official
openai/codexexecutes the complete hook command through the detected shell (-c, with$SHELL -lcfallback); hooks engine history shows that behavior from its initial implementation. The proposed direct/bin/sh <path>launcher removed Orca's missing/unreadable-script guard and stdin drain. With a missing managed script and a 1 MiB payload, it reproducibly returned exit 127 and raisedEPIPEunder both-cand-lc. It also could not represent paths containing spaces under the hypothesized naive whitespace splitter.Head
305bf6b8ecc5826e06b3e414eafba4ff129f70aarestores the guarded launchers before closure, so this branch is no longer unsafe to check out. Relative tomain, the remaining production diff is only compatibility bookkeeping for direct trust hashes emitted by this unmerged PR; that is not a justified long-term product change.Related: #8110 remains open. Closing it requires the reporter's exact
codex --version, binary provenance, and actual child argv/runner trace.Verification
-cand-lcproduced exit 127 pluswrite EPIPE.pnpm run typecheckpassed.pnpm run lintpassed, including reliability, max-lines, and localization gates.oxfmt --checkon all 6 changed files passed.git diff --checkpassed.Primary evidence
openai/codexcommand_runner.rs: the complete command is appended to shell args and stdin is written after spawn.openai/codexsession shell wiring: detected POSIX shells use-c; fallback uses$SHELL -lc.